<?php
	class Xhtml {

		private $default_html_header_doctype			= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
		private $default_html_header_lang				= "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"ko\" xml:lang=\"ko\">";
		private $default_html_header_head				= "<head>";
		private $default_html_header_title				= "<title></title>";
		private $default_html_header_meta_charset		= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
		private $default_html_header_meta_compatible	= "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=9\">";
		private $default_html_header_link_favicon;
		private $default_html_header_link_style;
		private $default_html_header_link_script;
		private $default_html_header_head_end			= "</head>";
		private $default_html_header_body_start			= "<body>";

		private $default_html_footer_tag				= "</body>\n</html>";

		public function __construct(){
		}

		####################################################
		# oop                                              #
		####################################################

		#	exaple)
		#		$html->set_title("template");
		#		$html->set_script($JS."jquery-1.7.1.min.js".$VersionTime);
		#		$html->set_style($CSS."style.css".$VersionTime);
		#		$html->html_header();
		#		$html->html_footer();

		public function html_header(){
			printf("%s", $this->default_html_header_doctype.PHP_EOL);
			printf("%s", $this->default_html_header_lang.PHP_EOL);
			printf("%s", $this->default_html_header_head.PHP_EOL);
			printf("%s", $this->default_html_header_title.PHP_EOL);
			printf("%s", $this->default_html_header_meta_charset.PHP_EOL);
			printf("%s", $this->default_html_header_meta_compatible.PHP_EOL);
			printf("%s", $this->default_html_header_link_style.PHP_EOL);
			printf("%s", $this->default_html_header_link_script.PHP_EOL);
			printf("%s", $this->default_html_header_link_favicon.PHP_EOL);
			printf("%s", $this->default_html_header_head_end.PHP_EOL);
			printf("%s", $this->default_html_header_body_start.PHP_EOL);
		}

		public function html_footer(){
			printf("%s", $this->default_html_footer_tag.PHP_EOL);
			exit();
		}

		public function set_title($param_text){
			$this->default_html_header_title = sprintf("<title>%s</title>", $param_text);
		}

		public function set_style($param_text){
			$this->default_html_header_link_style .= sprintf(PHP_EOL."<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />", $param_text);
		}

		public function set_script($param_text){
			$this->default_html_header_link_style .= sprintf(PHP_EOL."<script src=\"%s\" type=\"text/javascript\"></script>", $param_text);
		}

		public function set_favicon($param_text){
			$this->default_html_header_link_favicon .= sprintf(PHP_EOL."<link rel=\"shortcut icon\" href=\"%s\" type=\"image/x-ico\" />", $param_text);
		}



		####################################################
		# custom                                           #
		####################################################

		public function custom_header($title='') {
			$this->set_title($title);
			$this->set_favicon('/img/favicon.ico');
			$ret = trim(sprintf("%s", $this->default_html_header_doctype.PHP_EOL));
			$ret .= sprintf("\n%s", $this->default_html_header_lang.PHP_EOL);
			$ret .= sprintf("%s", $this->default_html_header_head.PHP_EOL);
			$ret .= sprintf("\t%s", $this->default_html_header_title.PHP_EOL);
			$ret .= sprintf("\t%s", $this->default_html_header_meta_charset.PHP_EOL);
			$ret .= sprintf("\t%s", $this->default_html_header_link_favicon.PHP_EOL);
			return $ret;
		}

		public function custom_js($js) {
			return sprintf(PHP_EOL."\t<script type=\"text/javascript\" src=\"%s\"></script>", $js);
		}

		public function custom_css($css) {
			return sprintf(PHP_EOL."\t<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />", $css);
		}

		public function custom_body() {
			$ret = sprintf("\n%s", $this->default_html_header_head_end.PHP_EOL);
			$ret .= sprintf("%s", $this->default_html_header_body_start.PHP_EOL);
			return $ret;
		}

		public function custom_footer() {
			return $this->html_footer;
		}

	}